package miaofusdk

import (
	"encoding/json"
	"fmt"
	"gitee.com/garlic/tools"
	"github.com/astaxie/beego/logs"
)

/**
商品管理服务
*/

//桌码数据
type TableInfoBean struct {
	Id          int    `json:"id,omitempty,string"`
	TableNum    string `json:"table_num,omitempty"`
	TableName   string `json:"table_name,omitempty"`
	TableType   string `json:"table_type,omitempty"`
	PeopleMax   int    `json:"people_max,omitempty,string"`
	PeopleMin   int    `json:"people_min,omitempty,string"`
	ShopId      string `json:"shop_id,omitempty"`
	StoreCode   string `json:"store_code,omitempty"`
	MerchantPid string `json:"merchant_pid,omitempty"`
	Status      string `json:"status,omitempty"`
	TradeNo     string `json:"trade_no"`
	SysTag      string `json:"sys_tag,omitempty"`
	Marker      string `json:"marker,omitempty"`
}

type RespTableInfo struct {
	Response
	Data TableInfoBean `json:"data,omitempty"`
}

type RespTableInfos struct {
	Response
	Page       int             `json:"page,string"`
	Rows       int             `json:"rows,string"`
	TotalCount int             `json:"total_count,string"`
	TotalPage  int             `json:"total_page,string"`
	List       []TableInfoBean `json:"list,omitempty,string"`
}

func (s *SrvMfGoodsManager) CreateTable(bean TableInfoBean) (RespTableInfo, error) {
	resp := RespTableInfo{}
	http_request := s.GetPost(s.GetUrl() + "/mfgoods/table/insert/" + bean.StoreCode)
	m := tools.JsonToMap(bean)
	for k, _ := range m {
		value := fmt.Sprintf("%v", m[k])
		if value != "" {
			http_request.Param(k, value)
		}
	}
	if v, err := http_request.Bytes(); err != nil {
		return resp, err
	} else if err := json.Unmarshal(v, &resp); err != nil {
		return resp, err
	} else {
		return resp, nil
	}
}

func (s *SrvMfGoodsManager) DeleteTable(store_code string, id int) (Response, error) {
	resp := Response{}
	http_request := s.GetPost(s.GetUrl() + "/mfgoods/table/delete/" + store_code)
	http_request.Param("id", fmt.Sprintf("%d", id))
	if v, err := http_request.Bytes(); err != nil {
		return resp, err
	} else if err := json.Unmarshal(v, &resp); err != nil {
		return resp, err
	} else {
		return resp, nil
	}
}

func (s *SrvMfGoodsManager) ReadTable(store_code, query_type, query_value string) (RespTableInfo, error) {
	resp := RespTableInfo{}
	http_request := s.GetPost(s.GetUrl() + "/mfgoods/table/read/" + store_code)
	http_request.Param("query_type", query_type)
	http_request.Param("query_value", query_value)
	if v, err := http_request.Bytes(); err != nil {
		return resp, err
	} else if err := json.Unmarshal(v, &resp); err != nil {
		return resp, err
	} else {
		return resp, nil
	}
}

func (s *SrvMfGoodsManager) ReadTableByMarker(marker string) (RespTableInfo, error) {
	resp := RespTableInfo{}
	http_request := s.GetPost(s.GetUrl() + "/mfgoods/table/marker/" + marker)
	if v, err := http_request.Bytes(); err != nil {
		return resp, err
	} else if err := json.Unmarshal(v, &resp); err != nil {
		return resp, err
	} else {
		return resp, nil
	}
}

func (s *SrvMfGoodsManager) UpdateTable(bean TableInfoBean) (RespTableInfo, error) {
	resp := RespTableInfo{}
	http_request := s.GetPost(s.GetUrl() + "/mfgoods/table/update/" + bean.StoreCode)
	m := tools.JsonToMap(bean)
	for k, _ := range m {
		value := fmt.Sprintf("%v", m[k])
		if value != "" {
			http_request.Param(k, value)
		}
	}
	if v, err := http_request.Bytes(); err != nil {
		return resp, err
	} else if err := json.Unmarshal(v, &resp); err != nil {
		logs.Error(err, string(v))
		return resp, err
	} else {
		return resp, nil
	}
}

/**
table_num__contains
*/
func (s *SrvMfGoodsManager) ListTable(page, rows int, store_code, query_type, query_value string) (RespTableInfos, error) {
	resp := RespTableInfos{}
	http_request := s.GetPost(s.GetUrl() + "/mfgoods/table/list/" + store_code)
	http_request.Param("page", fmt.Sprintf("%d", page))
	http_request.Param("rows", fmt.Sprintf("%d", rows))
	http_request.Param("query_type", query_type)
	http_request.Param("query_value", query_value)
	if v, err := http_request.Bytes(); err != nil {
		return resp, err
	} else if err := json.Unmarshal(v, &resp); err != nil {
		return resp, err
	} else {
		return resp, nil
	}
}

type GoodsRemarkBean struct {
	Id        int    `json:"id,omitempty,string"`
	Name      string `json:"name,omitempty"`
	StoreCode string `json:"store_code,omitempty"`
	OrderTag  int    `json:"order_tag"`
	SysTag    string `json:"sys_tag,omitempty"`
}

type RespGoodsRemarkBean struct {
	Response
	Data GoodsRemarkBean `json:"data,omitempty"`
}

type RespGoodsRemarkBeans struct {
	Response
	Page       int               `json:"page,string"`
	Rows       int               `json:"rows,string"`
	TotalCount int               `json:"total_count,string"`
	TotalPage  int               `json:"total_page,string"`
	List       []GoodsRemarkBean `json:"list,omitempty,string"`
}

func (s *SrvMfGoodsManager) CreateGoodsRemark(bean GoodsRemarkBean) (RespGoodsRemarkBean, error) {
	resp := RespGoodsRemarkBean{}
	http_request := s.GetPost(s.GetUrl() + "/mfgoods/remark/insert/" + bean.StoreCode)
	m := tools.JsonToMap(bean)
	for k, _ := range m {
		value := fmt.Sprintf("%v", m[k])
		if value != "" {
			http_request.Param(k, value)
		}
	}
	if v, err := http_request.Bytes(); err != nil {
		return resp, err
	} else if err := json.Unmarshal(v, &resp); err != nil {
		return resp, err
	} else {
		return resp, nil
	}
}

func (s *SrvMfGoodsManager) DeleteGoodsRemark(store_code string, id int) (Response, error) {
	resp := Response{}
	http_request := s.GetPost(s.GetUrl() + "/mfgoods/remark/delete/" + store_code)
	http_request.Param("id", fmt.Sprintf("%d", id))
	if v, err := http_request.Bytes(); err != nil {
		return resp, err
	} else if err := json.Unmarshal(v, &resp); err != nil {
		return resp, err
	} else {
		return resp, nil
	}
}

func (s *SrvMfGoodsManager) ReadGoodsRemark(store_code string, id int) (RespGoodsRemarkBean, error) {
	resp := RespGoodsRemarkBean{}
	http_request := s.GetPost(s.GetUrl() + "/mfgoods/remark/read/" + store_code)
	http_request.Param("id", fmt.Sprintf("%d", id))
	if v, err := http_request.Bytes(); err != nil {
		return resp, err
	} else if err := json.Unmarshal(v, &resp); err != nil {
		return resp, err
	} else {
		return resp, nil
	}
}

func (s *SrvMfGoodsManager) UpdateGoodsRemark(bean GoodsRemarkBean) (RespGoodsRemarkBean, error) {
	resp := RespGoodsRemarkBean{}
	http_request := s.GetPost(s.GetUrl() + "/mfgoods/remark/update/" + bean.StoreCode)
	m := tools.JsonToMap(bean)
	for k, _ := range m {
		value := fmt.Sprintf("%v", m[k])
		if value != "" {
			http_request.Param(k, value)
		}
	}
	if v, err := http_request.Bytes(); err != nil {
		return resp, err
	} else if err := json.Unmarshal(v, &resp); err != nil {
		return resp, err
	} else {
		return resp, nil
	}
}

func (s *SrvMfGoodsManager) ListGoodsRemark(page, rows int, store_code, name, sys_tag string) (RespGoodsRemarkBeans, error) {
	resp := RespGoodsRemarkBeans{}
	http_request := s.GetPost(s.GetUrl() + "/mfgoods/remark/list/" + store_code)
	http_request.Param("page", fmt.Sprintf("%d", page))
	http_request.Param("rows", fmt.Sprintf("%d", rows))
	http_request.Param("name", name)
	http_request.Param("sys_tag", sys_tag)
	if v, err := http_request.Bytes(); err != nil {
		return resp, err
	} else if err := json.Unmarshal(v, &resp); err != nil {
		return resp, err
	} else {
		return resp, nil
	}
}

type GoodsItemTypeBean struct {
	Id        int    `json:"id,omitempty,string"`
	TypeName  string `json:"type_name,omitempty"`
	ShopCode  string `json:"shop_code,omitempty"`
	PId       int    `json:"p_id,omitempty"`
	Level     int    `json:"level,omitempty"`
	Discounts string `json:"discounts"`
	OrderTag  int    `json:"order_tag"`
	SysTag    string `json:"sys_tag,omitempty"`
}

type RespGoodsItemType struct {
	Response
	Data GoodsItemTypeBean `json:"data,omitempty"`
}

type RespGoodsItemTypes struct {
	Response
	Page       int                 `json:"page,string"`
	Rows       int                 `json:"rows,string"`
	TotalCount int                 `json:"total_count,string"`
	TotalPage  int                 `json:"total_page,string"`
	List       []GoodsItemTypeBean `json:"list,omitempty,string"`
}

func (s *SrvMfGoodsManager) CreateGoodsType(bean GoodsItemTypeBean) (RespGoodsItemType, error) {
	resp := RespGoodsItemType{}
	http_request := s.GetPost(s.GetUrl() + "/mfgoods/goodstype/AddGoodsType")
	m := tools.JsonToMap(bean)
	for k, _ := range m {
		value := fmt.Sprintf("%v", m[k])
		if value != "" {
			http_request.Param(k, value)
		}
	}
	if v, err := http_request.Bytes(); err != nil {
		return resp, err
	} else if err := json.Unmarshal(v, &resp); err != nil {
		return resp, err
	} else {
		return resp, nil
	}
}

func (s *SrvMfGoodsManager) DeleteGoodsType(shop_code string, id int) (Response, error) {
	resp := Response{}
	http_request := s.GetPost(s.GetUrl() + "/mfgoods/goodstype/DelGoodsType")
	http_request.Param("shop_code", shop_code)
	http_request.Param("id", fmt.Sprintf("%d", id))
	if v, err := http_request.Bytes(); err != nil {
		return resp, err
	} else if err := json.Unmarshal(v, &resp); err != nil {
		return resp, err
	} else {
		return resp, nil
	}
}

func (s *SrvMfGoodsManager) ReadGoodsType(shop_code string, id int) (RespGoodsItemType, error) {
	resp := RespGoodsItemType{}
	http_request := s.GetPost(s.GetUrl() + "/mfgoods/goodstype/GoodsTypeMsg")
	http_request.Param("shop_code", shop_code)
	http_request.Param("id", fmt.Sprintf("%d", id))
	if v, err := http_request.Bytes(); err != nil {
		return resp, err
	} else if err := json.Unmarshal(v, &resp); err != nil {
		return resp, err
	} else {
		return resp, nil
	}
}

func (s *SrvMfGoodsManager) UpdateGoodsType(bean GoodsItemTypeBean) (RespGoodsItemType, error) {
	resp := RespGoodsItemType{}
	http_request := s.GetPost(s.GetUrl() + "/mfgoods/goodstype/UpdateGoodsType")
	m := tools.JsonToMap(bean)
	for k, _ := range m {
		value := fmt.Sprintf("%v", m[k])
		if value != "" {
			http_request.Param(k, value)
		}
	}
	if v, err := http_request.Bytes(); err != nil {
		return resp, err
	} else if err := json.Unmarshal(v, &resp); err != nil {
		return resp, err
	} else {
		return resp, nil
	}
}

func (s *SrvMfGoodsManager) ListGoodsType(page, rows int, shop_code, type_name, sys_tag string) (RespGoodsItemTypes, error) {
	resp := RespGoodsItemTypes{}
	http_request := s.GetPost(s.GetUrl() + "/mfgoods/goodstype/AllTypeList")
	http_request.Param("page", fmt.Sprintf("%d", page))
	http_request.Param("rows", fmt.Sprintf("%d", rows))
	http_request.Param("shop_code", shop_code)
	http_request.Param("type_name", type_name)
	http_request.Param("sys_tag", sys_tag)
	if v, err := http_request.Bytes(); err != nil {
		return resp, err
	} else if err := json.Unmarshal(v, &resp); err != nil {
		return resp, err
	} else {
		return resp, nil
	}
}

type GoodsItemBean struct {
	Id           int    `json:"id,omitempty,string"`
	GoodsCode    string `json:"goods_code,omitempty"`
	GoodsName    string `json:"goods_name,omitempty"`
	ImgUrl       string `json:"img_url,omitempty"`
	OldPrice     string `json:"old_price,omitempty"`
	NowPrice     string `json:"now_price,omitempty"`
	TypeId       int    `json:"type_id,omitempty,string"`
	TypeName     string `json:"type_name,omitempty"`
	SizeName     string `json:"size_name,omitempty"`
	StoreCode    string `json:"store_code,omitempty"`
	StoreName    string `json:"store_name,omitempty"`
	ShopCode     string `json:"shop_code,omitempty"`
	ShopName     string `json:"shop_name,omitempty"`
	OrderTag     int    `json:"order_tag,omitempty"`
	UnderState   string `json:"under_state,omitempty"`
	TodayUnsold  int    `json:"today_unsold"`
	TodaySold    int    `json:"today_sold"`
	DefaultStock int    `json:"default_stock"`
	SysTag       string `json:"sys_tag,omitempty"`
	Desc         string `json:"desc,omitempty"`

	Discounts    string `json:"discounts"` //是否参与打折信息  Y、N
	SizeId       int    `json:"size_id"`
	Coupon       string `json:"coupon"`        //是否参与优惠  Y、N
	VipPrice     string `json:"vip_price"`     //会员价格
	Service      string `json:"service"`       //是否需要技师服务  Y、N
	ServiceTime  int    `json:"service_time"`  //服务时长，默认为60分钟，以秒来保存
	RewardPrice  string `json:"reward_price"`  //技师抽成
	EmployeeId   int    `json:"employee_id"`   //技师id
	EmployeeName string `json:"employee_name"` //技师名字
}

type RespGoodsItem struct {
	Response
	Data GoodsItemBean `json:"data,omitempty"`
}

type RespGoodsItems struct {
	Response
	Page       int             `json:"page,string"`
	Rows       int             `json:"rows,string"`
	TotalCount int             `json:"total_count,string"`
	TotalPage  int             `json:"total_page,string"`
	List       []GoodsItemBean `json:"list,omitempty,string"`
}

func (s *SrvMfGoodsManager) CreateGoods(bean GoodsItemBean) (RespGoodsItem, error) {
	resp := RespGoodsItem{}
	http_request := s.GetPost(s.GetUrl() + "/mfgoods/goods/AddGoods")
	m := tools.JsonToMap(bean)
	for k, _ := range m {
		value := fmt.Sprintf("%v", m[k])
		if value != "" {
			http_request.Param(k, value)
		}
	}
	if v, err := http_request.Bytes(); err != nil {
		return resp, err
	} else if err := json.Unmarshal(v, &resp); err != nil {
		return resp, err
	} else {
		return resp, nil
	}
}

func (s *SrvMfGoodsManager) DeleteGoods(id int) (Response, error) {
	resp := Response{}
	http_request := s.GetPost(s.GetUrl() + "/mfgoods/goods/DelGoods")
	http_request.Param("id", fmt.Sprintf("%d", id))
	if v, err := http_request.Bytes(); err != nil {
		return resp, err
	} else if err := json.Unmarshal(v, &resp); err != nil {
		return resp, err
	} else {
		return resp, nil
	}
}

func (s *SrvMfGoodsManager) ReadGoods(id int) (RespGoodsItem, error) {
	resp := RespGoodsItem{}
	http_request := s.GetPost(s.GetUrl() + "/mfgoods/goods/GoodsMsg")
	http_request.Param("id", fmt.Sprintf("%d", id))
	if v, err := http_request.Bytes(); err != nil {
		return resp, err
	} else if err := json.Unmarshal(v, &resp); err != nil {
		return resp, err
	} else {
		return resp, nil
	}
}

func (s *SrvMfGoodsManager) UpdateGoods(bean GoodsItemBean) (RespGoodsItem, error) {
	resp := RespGoodsItem{}
	http_request := s.GetPost(s.GetUrl() + "/mfgoods/goods/UpdateGoods")
	m := tools.JsonToMap(bean)
	for k, _ := range m {
		value := fmt.Sprintf("%v", m[k])
		if value != "" {
			http_request.Param(k, value)
		}
	}
	if v, err := http_request.Bytes(); err != nil {
		return resp, err
	} else if err := json.Unmarshal(v, &resp); err != nil {
		return resp, err
	} else {
		return resp, nil
	}
}

//估清
func (s *SrvMfGoodsManager) ClearGoods(bean GoodsItemBean) (RespGoodsItem, error) {
	resp := RespGoodsItem{}
	http_request := s.GetPost(s.GetUrl() + "/mfgoods/goods/clear")
	m := tools.JsonToMap(bean)
	for k, _ := range m {
		value := fmt.Sprintf("%v", m[k])
		if value != "" {
			http_request.Param(k, value)
		}
	}
	if v, err := http_request.Bytes(); err != nil {
		return resp, err
	} else if err := json.Unmarshal(v, &resp); err != nil {
		return resp, err
	} else {
		return resp, nil
	}
}

func (s *SrvMfGoodsManager) ListGoods(page, rows int, bean GoodsItemBean) (RespGoodsItems, error) {
	resp := RespGoodsItems{}
	http_request := s.GetPost(s.GetUrl() + "/mfgoods/goods/GoodsList")
	http_request.Param("page", fmt.Sprintf("%d", page))
	http_request.Param("rows", fmt.Sprintf("%d", rows))
	m := tools.JsonToMap(bean)
	for k, _ := range m {
		value := fmt.Sprintf("%v", m[k])
		if value != "" {
			http_request.Param(k, value)
		}
	}
	if v, err := http_request.Bytes(); err != nil {
		return resp, err
	} else if err := json.Unmarshal(v, &resp); err != nil {
		return resp, err
	} else {
		return resp, nil
	}
}

//商品优惠策略
type CouponPolicyItemBean struct {
	Id                  int    `json:"id"`                     //自增型主键ID
	MainGoodsId         int    `json:"main_goods_id"`          //参与优惠策略的id
	MainGoodsName       string `json:"main_goods_name"`        //参与优惠策略的商品name
	CouponGoodsId       int    `json:"coupon_goods_id"`        //优惠商品的id
	CouponGoodsName     string `json:"coupon_goods_name"`      //优惠商品的name
	CouponGoodsOldPrice string `json:"coupon_goods_old_price"` //优惠的原价
	CouponGoodsNowPrice string `json:"coupon_goods_now_price"` //优惠的现价
	CouponGoodsVipPrice string `json:"coupon_goods_vip_price"` //会员价
}

type RespCouponPolicy struct {
	Response
	Data CouponPolicyItemBean `json:"data,omitempty"`
}

type RespCouponPolicys struct {
	Response
	Page       int                    `json:"page,string"`
	Rows       int                    `json:"rows,string"`
	TotalCount int                    `json:"total_count,string"`
	TotalPage  int                    `json:"total_page,string"`
	List       []CouponPolicyItemBean `json:"list,omitempty,string"`
}

//创建优惠策略
func (s *SrvMfGoodsManager) CreateCouponPolicy(bean CouponPolicyItemBean) (RespCouponPolicy, error) {
	resp := RespCouponPolicy{}
	http_request := s.GetPost(s.GetUrl() + "/mfgoods/couponpolicy/AddCouponPolicy")
	m := tools.JsonToMap(bean)
	for k, _ := range m {
		value := fmt.Sprintf("%v", m[k])
		if value != "" {
			http_request.Param(k, value)
		}
	}
	if v, err := http_request.Bytes(); err != nil {
		return resp, err
	} else if err := json.Unmarshal(v, &resp); err != nil {
		return resp, err
	} else {
		return resp, nil
	}
}

//删除优惠策略
func (s *SrvMfGoodsManager) DeleteCouponPolicy(id int) (Response, error) {
	resp := Response{}
	http_request := s.GetPost(s.GetUrl() + "/goodssize/couponpolicy/DelCouponPolicy")
	http_request.Param("id", fmt.Sprintf("%d", id))
	if v, err := http_request.Bytes(); err != nil {
		return resp, err
	} else if err := json.Unmarshal(v, &resp); err != nil {
		return resp, err
	} else {
		return resp, nil
	}
}

//优惠策略详情
func (s *SrvMfGoodsManager) ReadCouponPolicy(id int) (RespCouponPolicy, error) {
	resp := RespCouponPolicy{}
	http_request := s.GetPost(s.GetUrl() + "/mfgoods/couponpolicy/CouponPolicyMsg")
	http_request.Param("id", fmt.Sprintf("%d", id))
	if v, err := http_request.Bytes(); err != nil {
		return resp, err
	} else if err := json.Unmarshal(v, &resp); err != nil {
		return resp, err
	} else {
		return resp, nil
	}
}

//更新优惠策略
func (s *SrvMfGoodsManager) UpdateCouponPolicy(bean CouponPolicyItemBean) (RespCouponPolicy, error) {
	resp := RespCouponPolicy{}
	http_request := s.GetPost(s.GetUrl() + "/mfgoods/couponpolicy/UpdateCouponPolicy")
	m := tools.JsonToMap(bean)
	for k, _ := range m {
		value := fmt.Sprintf("%v", m[k])
		if value != "" {
			http_request.Param(k, value)
		}
	}
	if v, err := http_request.Bytes(); err != nil {
		return resp, err
	} else if err := json.Unmarshal(v, &resp); err != nil {
		return resp, err
	} else {
		return resp, nil
	}
}

//优惠策略列表
func (s *SrvMfGoodsManager) ListCouponPolicy(page, rows int, bean CouponPolicyItemBean) (RespCouponPolicy, error) {
	resp := RespCouponPolicy{}
	http_request := s.GetPost(s.GetUrl() + "/mfgoods/couponpolicy/GoodsSizeList")
	http_request.Param("page", fmt.Sprintf("%d", page))
	http_request.Param("rows", fmt.Sprintf("%d", rows))
	m := tools.JsonToMap(bean)
	for k, _ := range m {
		value := fmt.Sprintf("%v", m[k])
		if value != "" {
			http_request.Param(k, value)
		}
	}
	if v, err := http_request.Bytes(); err != nil {
		return resp, err
	} else if err := json.Unmarshal(v, &resp); err != nil {
		return resp, err
	} else {
		return resp, nil
	}
}

//商品规格
type SizeItemBean struct {
	Id       int    `json:"id"`        //自增型主键ID
	SizeName string `json:"size_name"` //规格名称
	Shopid   int    `json:"shopid"`    //商户id
	SysTag   string `json:"sys_tag"`   //系统标识
}

type RespSize struct {
	Response
	Data SizeItemBean `json:"data,omitempty"`
}

type ResSizes struct {
	Response
	Page       int            `json:"page,string"`
	Rows       int            `json:"rows,string"`
	TotalCount int            `json:"total_count,string"`
	TotalPage  int            `json:"total_page,string"`
	List       []SizeItemBean `json:"list,omitempty,string"`
}

//创建规格
func (s *SrvMfGoodsManager) CreateGoodsSize(bean SizeItemBean) (RespSize, error) {
	resp := RespSize{}
	http_request := s.GetPost(s.GetUrl() + "/mfgoods/goodssize/AddGoodsSize")
	m := tools.JsonToMap(bean)
	for k, _ := range m {
		value := fmt.Sprintf("%v", m[k])
		if value != "" {
			http_request.Param(k, value)
		}
	}
	if v, err := http_request.Bytes(); err != nil {
		return resp, err
	} else if err := json.Unmarshal(v, &resp); err != nil {
		return resp, err
	} else {
		return resp, nil
	}
}

//删除规格
func (s *SrvMfGoodsManager) DeleteGoodsSize(id int) (Response, error) {
	resp := Response{}
	http_request := s.GetPost(s.GetUrl() + "/mfgoods/goodssize/DelGoodsSize")
	http_request.Param("id", fmt.Sprintf("%d", id))
	if v, err := http_request.Bytes(); err != nil {
		return resp, err
	} else if err := json.Unmarshal(v, &resp); err != nil {
		return resp, err
	} else {
		return resp, nil
	}
}

//规格详情
func (s *SrvMfGoodsManager) ReadGoodsSzie(id int) (RespSize, error) {
	resp := RespSize{}
	http_request := s.GetPost(s.GetUrl() + "/mfgoods/goodssize/GoodsSizeMsg")
	http_request.Param("id", fmt.Sprintf("%d", id))
	if v, err := http_request.Bytes(); err != nil {
		return resp, err
	} else if err := json.Unmarshal(v, &resp); err != nil {
		return resp, err
	} else {
		return resp, nil
	}
}

//更新规格
func (s *SrvMfGoodsManager) UpdateGoodsSize(bean SizeItemBean) (RespSize, error) {
	resp := RespSize{}
	http_request := s.GetPost(s.GetUrl() + "/mfgoods/goodssize/UpdateGoodsSize")
	m := tools.JsonToMap(bean)
	for k, _ := range m {
		value := fmt.Sprintf("%v", m[k])
		if value != "" {
			http_request.Param(k, value)
		}
	}
	if v, err := http_request.Bytes(); err != nil {
		return resp, err
	} else if err := json.Unmarshal(v, &resp); err != nil {
		return resp, err
	} else {
		return resp, nil
	}
}

//规格列表
func (s *SrvMfGoodsManager) ListGoodsSzie(page, rows int, bean SizeItemBean) (ResSizes, error) {
	resp := ResSizes{}
	http_request := s.GetPost(s.GetUrl() + "/mfgoods/goodssize/GoodsSizeList")
	http_request.Param("page", fmt.Sprintf("%d", page))
	http_request.Param("rows", fmt.Sprintf("%d", rows))
	m := tools.JsonToMap(bean)
	for k, _ := range m {
		value := fmt.Sprintf("%v", m[k])
		if value != "" {
			http_request.Param(k, value)
		}
	}
	if v, err := http_request.Bytes(); err != nil {
		return resp, err
	} else if err := json.Unmarshal(v, &resp); err != nil {
		return resp, err
	} else {
		return resp, nil
	}
}
